package com.itheima02.day03;

import java.util.Random;

/**
 * @author 刘全
 * @date 2021/7/18
 */
public class test05 {
    public static void main(String[] args) {
        useRandomNumHandler(new RandomNumHandler() {
            @Override
            public int getNumber() {
                Random r = new Random();
                int sum = r.nextInt(10)+1;
                return sum;
            }
        });
        useRandomNumHandler(() -> {
            Random r = new Random();
            int result = r.nextInt(10)+1;
            return result;
        });
    }
    public static void useRandomNumHandler(RandomNumHandler randomNumHandler){
        int result = randomNumHandler.getNumber();
        System.out.println(result);
    }
}
interface RandomNumHandler{
    int getNumber();
}